package com.Questions.DFS;


/**
 * 二叉树的最大深度
 */
public class leetcode104 {
    public int maxDepth(TreeNode root) {
        return searchDepth(root,0);
    }
    public int searchDepth(TreeNode root,int k){
        if(root==null){
            return k;
        }
        k++;
        int leftMax=searchDepth(root.left,k);
        int rightMax=searchDepth(root.right,k);
        return Math.max(leftMax,rightMax);
    }

}
